//
//  ZBTabbar.m
//  ZBMainFramework
//
//  Created by apple on 2018/10/24.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ZB_Tabbar.h"

@interface ZB_Tabbar()

@property (nonatomic, strong)  CALayer *lineLayer;

@end

@implementation ZB_Tabbar

- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]){
        // 设置样式, 去除tabbar上面的黑线
        [self.layer addSublayer:self.lineLayer];
        self.lineLayer.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 0.5);
        NSMutableDictionary *dictNormal = [NSMutableDictionary dictionary];
        [dictNormal setValue: [UIConstantColor getThemeNormalgaryColor]forKey:NSForegroundColorAttributeName];
        [dictNormal setValue: [UIFont systemFontOfSize:14.0] forKey:NSFontAttributeName];
        [[UITabBarItem appearance] setTitleTextAttributes:dictNormal forState:UIControlStateNormal];
        
        NSMutableDictionary *dictSelect = [NSMutableDictionary dictionary];
        [dictSelect setValue: [UIConstantColor getThemeColor] forKey:NSForegroundColorAttributeName];
        [dictSelect setValue: [UIFont systemFontOfSize:14.0] forKey:NSFontAttributeName];
        [[UITabBarItem appearance] setTitleTextAttributes:dictSelect forState:UIControlStateSelected];
        
        //背景颜色
        [[UITabBar appearance] setBarTintColor:[UIConstantColor getTabbarDefaultBackgroundColor]];
        [UITabBar appearance].translucent = NO;
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
}

- (CALayer *)lineLayer
{
    if(_lineLayer == nil)
    {
        _lineLayer = [CALayer layer];
        _lineLayer.backgroundColor = [UIColor redColor].CGColor;
    }
    return _lineLayer;
}

@end
